Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

downgrading ansi-regex version 4 to 3 - an arrow function was used in… #3181

Closed
wants to merge 1 commit into from

Conversation

iamsoorena
Copy link

since there was an arrow function used in strip-ansi version 4, next.js was throwing errors is versions 3+.
so we should either use the old version of strip-ansi or we should compile it.
more info about the problem of version 4 of strip-ansi is found here.

… version 4 that made next.js throwing errors in old browsers
@timneutkens timneutkens self-assigned this Nov 1, 2017
@ptomasroos
Copy link
Contributor

Word. Experiencing the same thing! @timneutkens

@haydn
Copy link

haydn commented Nov 2, 2017

Looks like this was fixed in #2860 and then reverted in 531d0a3.

@haydn
Copy link

haydn commented Nov 2, 2017

If you're using Yarn you can work around this issue with:

  "resolutions": {
    "next/strip-ansi": "3.0.1"
  }

See: https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

@iamsoorena
Copy link
Author

@haydn thank you it worked really well. although it doesn't work in Development but it works like a charm in Production.

@timneutkens
Copy link
Member

Applied a fix that didn't involve downgrading ansi-regex. It was being build into the production bundle, even though it wasn't being used (only in development). So this error is going in production mode. @iamsoorena has confirmed it works on slack 👍

@ptomasroos
Copy link
Contributor

In what version @timneutkens ?

@timneutkens
Copy link
Member

@ptomasroos next@canary

@mattywong
Copy link

@timneutkens doesn't seem to have been fixed in next@canary, still getting the ansiregex syntax error (arrow function) running with a custom server, so not sure if it's because of that?

@iamsoorena
Copy link
Author

iamsoorena commented Nov 24, 2017

@mattywong Did you try it in production environment?
because the problem hasn't been resolved in development environment yet.

@mattywong
Copy link

@timneutkens my bad, it's working fine now in production thanks!

@i8ramin
Copy link
Contributor

i8ramin commented Dec 8, 2017

So this still doesn't solve the "Fetch as Google / PageSpeed" problem. ie,
https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fdeploy-preview-38--candidco.netlify.com%2F

@DominikLevitsky
Copy link

The problem still persists.

@david-genger
Copy link

david-genger commented May 31, 2018

Anyone, please help, I just migrated to next on the promise of good SEO and now everything is in the air :-(
I can't use the solution from @timneutkens as I am using NPM.

https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fcompareali.com%2F

Runing NestJs version 6..

@david-genger
Copy link

I see that the Zeit.co website it's working properly! @rauchg what are you and your team doing in order it should work?

@timneutkens
Copy link
Member

timneutkens commented May 31, 2018

Next by itself doesn't need polyfills by default, but you're most likely using an external library does.

Example of basic Next.js:
https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fcreate-next-example-app-fnevuusuhp.nextjs.org%2F&tab=mobile

The with-polyfills example shows how to configure polyfills as-needed:
https://github.com/zeit/next.js/tree/canary/examples/with-polyfills

Since you asked, this is the polyfills we add:

import fill from 'core-js/library/fn/array/virtual/fill'
import includes from 'core-js/library/fn/string/virtual/includes'
import repeat from 'core-js/library/fn/string/virtual/repeat'
import startsWith from 'core-js/library/fn/string/virtual/starts-with'
import assign from 'core-js/library/fn/object/assign'

// Some of the NPM packages we included, use following methods without polyfills.
// So, we need to include these polyfills.
// (This is only needed for IE11)
Array.prototype.fill = fill
String.prototype.includes = includes
String.prototype.repeat = repeat
String.prototype.startsWith = startsWith
Object.assign = assign

@david-genger
Copy link

@timneutkens so basically every web app will need different polyfills in order to be supported in Chrome 41, the version that Google Bot uses?

@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants